using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter23
{
	/// <summary>
	/// Example02: Find the Resultant Force
	/// Consider three point charges located at the corners
	/// of a right triangle as shown in Figure, where q_1 = q_3
	/// = 5.0 \mu C, q_2 = -2.0 \mu C, and a = 0.10 m.
	/// Find the resultant force exerted on q_3.
	/// q_1 = (0,0), q_2 = (0,a), q_3 = (a,a)
	/// F_3 = -1.1 i + 7.9 j (N)	
	/// </summary>
	public class Example02
	{
		public Example02()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.ElectricCharge q1 = new L.ElectricCharge();
			q1.C = 5.0E-6;
			L.ElectricCharge q2 = new L.ElectricCharge();
			q2.C = -2.0E-6;
			L.ElectricCharge q3 = new L.ElectricCharge();
			q3.C = 5.0E-6;
			
			double a  = 0.1;
			L.Position r1 = new L.Position();
			L.Position r2 = new L.Position();
			r2.Y = a;
			L.Position r3 = new L.Position();
			r3.X = a;
			r3.Y = a;

			L.ElectricForce F3by1 = new L.ElectricForce(q1,r1,q3,r3);
			L.ElectricForce F3by2 = new L.ElectricForce(q2,r2,q3,r3);
			L.Vector f = F3by1 + F3by2;

			result+=Convert.ToString(f.X)+" i + ";
			result+=Convert.ToString(f.Y)+" j\r\n";
		}
	}
}
